var pile = (function () {
    function init() {
        setTimeout(function () {//防止先于-读取缓存执行
            load();
        }, 10)
    };

    $('#exampleTable').on('load-success.bs.table', function (e, data) {
        if (data.total && !data.rows.length) {
            $('#exampleTable').bootstrapTable('selectPage').bootstrapTable('refresh');
        }
    });
    var h = $(window).height() - 80;

    function load() {
        $('#exampleTable')
            .bootstrapTable(
                {
                    method: 'get',
                    url:jsctx + "/elecStation/listStation?limit=100&offset=1",
                    iconSize: 'outline',
                    toolbar: '#exampleToolbar',
                    striped: false,
                    dataType: "json",
                    pagination: false,
                    singleSelect: false,
                    cache: false,
                    pageSize: 1000,
                    pageList: [10, 20, 30],
                    // pageList: [10],
                    pageNumber: 1,
                    sidePagination: "server",
                    paginationShowPageGo: true,
                    height: h,
                    rightFixedColumns: true,
                    queryParams: function (params) {
                        return {
                            limit: params.limit,
                            offset: (params.offset / params.limit) + 1,
                             stationName: $("#stationName").val(),
                            pileNo: $("#pileNo").val(),
                            equipmentModel: $("#equipmentModel").val(),
                            status: $("#status").val()
                        };
                    },
                    columns: [
                        {
                            title: '#', field: '', width: '50', align: 'left',
                            formatter: function (value, row, index) {
                                return index + 1;
                            }
                        },

                        {field: 'stationName', title: '所属站点', align: 'center', width: '100'},
                        {field: 'operatorName', title: '所属加盟商', align: 'center', width: '100'},
                        {
                            field: 'stationStaus', title: '站点状态',
                            width: '100', align: 'center',
                            formatter: function (value, row, index) {
                                if (value == '0') {
                                    return '<span class="label label-success">停用</span>'
                                } else if (value == '1') {
                                    return '<span class="label label-info">正常</span>'
                                }
                            }
                        },
                        {field: 'totalPileNum', title: '充电桩数量', width: '100', align: 'center'},
                        {field: 'totalGunNum', title: '充电枪数量', width: '100', align: 'center'},

                    ],

                });
                //点击行数据时,进入查看界面
                $("#exampleTable").on("click-row.bs.table",function(e, row, $element){
                    // showElectric(row.elecStationId,row.stationName)
                    moveMap(row.longitude,row.latitude);
                    console.log(row);
                })

                //双击事件
                $('#exampleTable').on('dbl-click-row.bs.table', function (e, row, element){
                    showElectric(row.elecStationId,row.stationName)
                })



    }


    function goBack() {
        window.history.back();
    }
    return {
        init: init,
        goBack: goBack,
    };
})();


